package objectOutputStream;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

public class Demo1 {
    public static void main(String[] args) throws IOException {
        //序列化
        //1.创建要序列化的对象
        User user = new User("Jack",22);
        //2.创建序列化对象
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("IODemo\\user.txt"));;
        //3.序列化
        oos.writeObject(user);
        //4.释放资源
        oos.close();

    }
}
